﻿using Exceptionless;
using Exceptionless.Logging;
using System;
using System.Collections.Generic;
using System.Text;

namespace Shared.LogHelper
{
    /// <summary>
    /// 在Startup.cs的ConfigureServices方法注入ExceptionlessLogger
    /// services.AddSingleton<ILogger, ExceptionlessLogger>();
    /// </summary>
    public interface ILogger
    {   void Debug(string source,string message, params string[] tags);
        void Error(string source, string message, params string[] tags);
        void Fatal(string source, string message, params string[] tags);
        void Info(string source, string message, params string[] tags);
        void Off(string source, string message, params string[] tags);
        void Other(string source, string message, params string[] tags);
        void Trace(string source, string message, params string[] tags);
        void Warn(string source, string message, params string[] tags);
        void Debug(string message, params string[] tags);
        void Error(string message, params string[] tags);
        void Fatal(string message, params string[] tags);
        void Info(string message, params string[] tags);
        void Off(string message, params string[] tags);
        void Other(string message, params string[] tags);
        void Trace(string message, params string[] tags);
        void Warn(string message, params string[] tags);
    }
    public class ExceptionlessLogger : ILogger
    {
        public void Debug(string message, params string[] tags)
        {
            ExceptionlessClient.Default.CreateLog(message, LogLevel.Debug).AddTags(tags).Submit();
        }

        public void Debug(string source, string message, params string[] tags)
        {
            ExceptionlessClient.Default.CreateLog(source,message, LogLevel.Debug).AddTags(tags).Submit();
        }

        public void Error(string message, params string[] tags)
        {
            ExceptionlessClient.Default.CreateLog(message, LogLevel.Error).AddTags(tags).Submit();
        }

        public void Error(string source, string message, params string[] tags)
        {
            ExceptionlessClient.Default.CreateLog(source, message, LogLevel.Error).AddTags(tags).Submit();
        }

        public void Fatal(string message, params string[] tags)
        {
            ExceptionlessClient.Default.CreateLog(message, LogLevel.Fatal).AddTags(tags).Submit();
        }

        public void Fatal(string source, string message, params string[] tags)
        {
            ExceptionlessClient.Default.CreateLog(source, message, LogLevel.Fatal).AddTags(tags).Submit();
        }

        public void Info(string message, params string[] tags)
        {
            ExceptionlessClient.Default.CreateLog(message, LogLevel.Info).AddTags(tags).Submit();
        }

        public void Info(string source, string message, params string[] tags)
        {
            ExceptionlessClient.Default.CreateLog(source, message, LogLevel.Info).AddTags(tags).Submit();
        }

        public void Off(string message, params string[] tags)
        {
            ExceptionlessClient.Default.CreateLog(message, LogLevel.Off).AddTags(tags).Submit();
        }

        public void Off(string source, string message, params string[] tags)
        {
            ExceptionlessClient.Default.CreateLog(source, message, LogLevel.Off).AddTags(tags).Submit();
        }

        public void Other(string message, params string[] tags)
        {
            ExceptionlessClient.Default.CreateLog(message, LogLevel.Other).AddTags(tags).Submit();
        }

        public void Other(string source, string message, params string[] tags)
        {
            ExceptionlessClient.Default.CreateLog(source, message, LogLevel.Other).AddTags(tags).Submit();
        }

        public void Trace(string message, params string[] tags)
        {
            ExceptionlessClient.Default.CreateLog(message, LogLevel.Trace).AddTags(tags).Submit();
        }

        public void Trace(string source, string message, params string[] tags)
        {
            ExceptionlessClient.Default.CreateLog(source, message, LogLevel.Trace).AddTags(tags).Submit();
        }

        public void Warn(string message, params string[] tags)
        {
            ExceptionlessClient.Default.CreateLog(message, LogLevel.Warn).AddTags(tags).Submit();
        }

        public void Warn(string source, string message, params string[] tags)
        {
            ExceptionlessClient.Default.CreateLog(source, message, LogLevel.Warn).AddTags(tags).Submit();
        }
    }
}
